package com.woniu.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WavehouseRabbit {

    @Bean(name="num_exchange")
    public Exchange getExchange(){
        return ExchangeBuilder.directExchange("num_exchange").durable(true).build();
    }

    @Bean("num_queue")
    public Queue getQueue(){
        return QueueBuilder.durable("num_queue").build();
    }

    @Bean
    public Binding getBinding(@Qualifier("num_exchange") Exchange exchange,
                              @Qualifier("num_queue")Queue queue){
        return BindingBuilder.bind(queue).to(exchange).with("num.#").noargs();
    }
}
